#pragma once
#include "../../../../include/singleton.h"
#include "../../../../include/timer_interface.hpp"
class CTimer
{
public:
    virtual void OnTimer(void) = 0;

    inline HTIMER get_timer(void){return m_timer;}
    inline void set_timer(HTIMER timer){m_timer = timer;}

    inline INT32 get_elapse(void){return m_elapse;}
    inline INT32 get_count(void){return m_count;}
protected:
    HTIMER  m_timer;
    INT32   m_elapse;
    INT32   m_count;
};

class CTimerMgr :
    public ITimerResponse
{
    DECLARE_SINGLETON(CTimerMgr)
public:
    CTimerMgr(void);
    virtual ~CTimerMgr(void);

    bool Init(void);
    void UnInit(void);

    bool AddTimer(CTimer* timer, bool exact = false);
    bool ModTimer(CTimer* timer, bool exact = false);
    void DelTimer(CTimer* timer);

    bool Run(void);

    virtual void OnTimer(HTIMER hTimer, void* pData);
protected:
    ITimerManager*  m_timer_mgr;
};

class CTimerCloseServer :
    public CTimer
{
public:
    CTimerCloseServer()
    {
        m_count = -1;
        m_elapse = 1000;
    }

    virtual void OnTimer(void);
protected:
private:
};